<!DOCTYPE html>
<html lang="zh-CN">
  <head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<meta name="renderer" content="webkit">
<title>{$sys_name} - {$lang.reg}</title>
<!-- Bootstrap -->
<link href="/css/css/bootstrap.min.css" rel="stylesheet">
<link href="/css/css/reset.css" rel="stylesheet">
<link href="/css/css/style.css" rel="stylesheet">
<script src="/js/js/jquery-1.11.3.min.js" type="text/javascript" ></script>
<script src="/js/js/respond.js" type="text/javascript" ></script>
<script src="/js/js/echarts.common.min.js" type="text/javascript" ></script>
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="//cdn.bootcss.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="//cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body class="login_bg">
	<div class="login_logo">
		<dl>
			<dt><img src="/images/login_logo.png" alt=""></dt>
			<dd>
				<p>{$sys_name}</p>
				<span>
					<em></em>
					<small>
						XINGFUBA
				    </small>
					<em></em>
				</span>
			</dd>
		</dl>
	</div>
	<div class="clear"></div>
	<div class="login_list">
		<div class="login_title">
			<ul>
				<li><a href="{:U('User/Index/login')}">{$lang.login}</a></li>
				<li class="login_cur"><a style="cursor: pointer">{$lang.reg}</a></li>
			</ul>
		</div>
		<div class="login_form">
			<form action="{:U('Index/insert')}" method="POST" id="checkAdminForm"  name="myform" enctype="multipart/form-data">
				<div class="login_in">
					<dl>
						<dt><img src="/images/login1.png" alt=""></dt>
						<dd style="width: 80%"><input type="text" style="width: 100%" class="l_in" placeholder="请输入手机号" value="" name="username" id="username" onchange="checkuname()" ></dd>
						<span id="checkreg_eml" style="position: absolute;margin-left: -6.5rem; color: red"></span>
					</dl>
				</div>

				<div class="login_yzm" style="display: none">
					<input type="text" class="yzm_in" id="em_code"  name="em_code" placeholder="请输入email安全码">
					<span type="button" class="yzm" id="yzm" onclick="send_eml()" style="cursor: pointer">{$lang.sendemail}</span>
					<span id="checkem_code" style="position: absolute; margin-left: 1.7rem; color: red"></span>
				</div>

				<div class="login_in">
					<dl>
						<dt><img src="/images/login2.png" alt=""></dt>
						<dd style="width: 80%"><input type="password" style="width: 100%"  class="l_in" placeholder="请输入密码" value="" name="password" id="password"></dd>
						<span id="checkreg_pas" style="position: absolute; margin-left: -6.5rem; color: red"></span>
					</dl>
				</div>
				<div class="login_in">
					<dl>
						<dt><img src="/images/login3.png" alt=""></dt>
						<dd style="width: 80%"><input type="password"  style="width: 100%" class="l_in" placeholder="请再次输入密码" value="" name="password1" id="password1"></dd>
						<span id="checkreg_pas1" style="position: absolute; margin-left: -6.5rem; color: red"></span>
					</dl>
				</div>
				<div class="login_in">
					<dl>
						<dt><img src="/images/login4.png" alt=""></dt>
						<dd style="width: 80%"><input style="width: 100%" type="text" class="l_in" placeholder="推荐人账号" value="{$parent}" id="parent" name="parent" class="loginput f_l" <if condition="$parent neq ''"> readonly </if> ></dd>
					</dl>
				</div>

				<div class="login_in" style="border: none;display: none">
					<input type="text" class="yzm_in" placeholder="请输入验证码" id="code" name="code">
					<img src="{:U('Index/Index/makecode')}" style="margin-left: 10px" onclick="changethis(this)">
					<span id="checkreg_code" style="position: absolute; margin-left: 1.7rem; color: red"></span>
				</div>

				<div class="login_yzm" style="display: none">
					<input type="text" class="yzm_in" placeholder="请输入验证码">
					<a href="" class="yzm">获取邮箱验证码</a>
				</div>

				<div class="login_btn">
					<input name="doSubmit" type="button" class="btn_login" id="btnLogin" onclick="checkthis()" value="立即注册">
				</div>
			</form>
		</div>
	</div>

	<!--信息框-->
	<include file="Public/Home/Showmsg.html" />

<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="/js/js/bootstrap.js"></script>
	<script>
		var time = 60;
		function send_eml(){
			var checkuanme = checkuname();
			if(checkuanme == "true"){
				var email = $("#username").val();
				$.ajax({
					type:"GET",
					url:"{:U('User/Index/sendEmail')}",
					data:{email:email},
					dataType: "json",
					success:function(data){
						if(data.error == 0){ //发送成功

							var timer=null;
							var t=time;
							var m=0;
							var s=0;
							m=Math.floor(t/60%60);
							m<10&&(m='0'+m);
							s=Math.floor(t%60);
							function countDown(){
								s--;
								s<10&&(s='0'+s);
								if(s.length>=3){
									s=59;
									m="0"+(Number(m)-1);
								}
								if(m.length>=3){
									m='00';
									s='00';
									clearInterval(timer);
								}

								document.getElementById("yzm").innerHTML="已发送 ("+ s +")";
								document.getElementById("yzm").onclick="";
								if(s == '00'){
									document.getElementById("yzm").innerHTML="发送邮箱安全码";
									document.getElementById("yzm").onclick= send_eml;
								}
								console.log(s);
							}
							timer=setInterval(countDown,1000);
						}else{
							document.getElementById("showmsg").innerHTML=data.msg;
							$("#sysmsg").show();
						}
					}
				});
			}
		}

		function changethis(obj){
			obj.src = "{:U('Index/Index/makecode')}"+'&r='+Math.random();
		}
		function register(){
			window.location.href = "{:U('Register/Index/index')}";
		}
		function deleuser(){
			document.getElementById("username").value = "";
		}
		function deleuser2(){
			document.getElementById("phone").value = "";
		}
		function deleuser4(){
			document.getElementById("parentnum").value = "";
		}
		function showpass(){
			var pass=document.getElementById("password");
			if( pass.type == "text"){
				pass.type="password";
				document.getElementById("log-pass").src="Public/Common/pics/log-pass-s.png"
			}else{
				pass.type="text";
				document.getElementById("log-pass").src="Public/Common/pics/log-pass-sl.png"
			}
		}
		function showpass1(){
			var pass=document.getElementById("password1");
			if( pass.type == "text"){
				pass.type="password";
				document.getElementById("log-pass1").src="Public/Common/pics/log-pass-s.png"
			}else{
				pass.type="text";
				document.getElementById("log-pass1").src="Public/Common/pics/log-pass-sl.png"
			}
		}

		var reg = false;
		function checkuname(){
			var uname = document.getElementById("username").value;
			var obj = document.getElementById("checkreg_eml"); // 获取对象
			$.ajax({
				type:"GET",
				url:"{:U('Index/check')}",
				data:{uname:uname},
				dataType: "json",
				success:function(data){
					if(data != null){         /*将返回的信息写入对象*/
						if(data != ''){
							obj.innerHTML = data;
							document.getElementById("yzm").onclick="";
							reg = false;
						}else{
							obj.innerHTML = "";
							document.getElementById("yzm").onclick= send_eml;
							reg = true;
						}
					}
				}
			});
			if(reg == false){
				return "false";
			}else{
				return "true";
			}
		}

		function checkthis(){
			checkuname();
			var unamereg = /^[1][3,4,5,7,8,9][0-9]{9}$/;;
			var username = document.myform.username.value;
			var password = document.myform.password.value;
			var password1 = document.myform.password1.value;
			var parent = document.myform.parent.value;
			var code = document.myform.code.value;
			var em_code = document.myform.em_code.value;
			if(username == ''){
				$("#checkreg_eml").text("输入用户名");
				reg = false;
			}else if(unamereg.test(username) === false) {
				$("#checkreg_eml").text("格式不正确");
				reg = false;
			}else{
				/*$("#checkreg_eml").text("");
				if(em_code == ''){
					//document.getElementById("showmsg").innerHTML="email安全码不能为空";
					$("#sysmsg").show();
					//reg = false;
				}else if(em_code.length < 6){
					//document.getElementById("showmsg").innerHTML="email安全码不能少于6位";
					$("#sysmsg").show();
					//reg = false;
				}else{*/
					$("#checkem_code").text("");
					if(password == ''){
						$("#checkreg_pas").text("不能为空");
						reg = false;
					}else if(password.length < 6){
						$("#checkreg_pas").text("不能少于6位");
						reg = false;
					}else{
						$("#checkreg_pas").text("");
						if(password1 == ''){
							$("#checkreg_pas1").text("再次输入密码");
							reg = false;
						}else if(password != password1){
							$("#checkreg_pas1").text("密码不一致");
							reg = false;
						}else{
							$("#checkreg_pas1").text("");
							/*if(code == ''){
								document.getElementById("showmsg").innerHTML="验证码不能为空";
								$("#sysmsg").show();
								reg = false;
							}else{*/
								reg = true;
							/*}*/
						}
					}
				}
			/*}*/
			if(reg==true){
				document.myform.submit();
			}

		}

		function login(){
			window.location.href = "{:U('User/Index/login')}";
		}
	</script>
</body>
</html>